//
// Created by HP on 2022/1/31.
//

#ifndef TMC_TMC_WINDOW_H
#define TMC_TMC_WINDOW_H

#include "tmc_utils.h"

// libs
#include "GLFW/glfw3.h"

// std
#include <string>

namespace tmc {
    class TmcWindow {
    public:
        TmcWindow(int w, int h, std::string name);
        ~TmcWindow();

        DELETE_COPY(TmcWindow);
        bool shouldClose() { return glfwWindowShouldClose(window); };
        GLFWwindow* getGLFWwindow() { return window; }
        float getAspectRatio() const { return static_cast<float>(width) / static_cast<float>(height); }
        void getCursorPos(double *xPos, double *yPos);
        void swapBuffers() { glfwSwapBuffers(window); }
    private:
        static void framebufferResizedCallback(GLFWwindow *window, int width, int height);
        static void cursorEnterCallback(GLFWwindow* window, int entered);
        static void mouseButtonInputCallback(GLFWwindow* window, int button, int action, int mods);
        static void keyboardInputCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
        void initWindow();

        int height{};
        int width{};
        bool framebufferResized = false;
        bool isEnter = false;
        std::string name{};
        GLFWwindow *window = nullptr;
    };
}

#endif //TMC_TMC_WINDOW_H
